package code08_常用类.内部类;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test03_静态内部类 {
    public static void main(String[] args) {
        // 在非外部类中实例化内部类
        OuterThree outer = new OuterThree();
        // 方式一:将外部类.内部类作为一个完整的类名
        OuterThree.InnerThree inner = new OuterThree.InnerThree();
        // 方式二:导包的时候将内部类所在的外部类也导入
        OuterThree.InnerThree innerThree = new OuterThree.InnerThree();

//        outer.show();
        innerThree.print();
    }
}
class OuterThree{
    private String name="admin";
    private int age=20;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public void show(){
        // 在外部类中实例化内部类,正常实例化即可
        InnerThree innerThree = new InnerThree();
        System.out.println(name);
        System.out.println(age);
        System.out.println(innerThree.name);
        System.out.println(innerThree.phone);
    }
    static class InnerThree{
        private String name="jack";
        private String phone="123456789";
        public void print(){
            System.out.println(name);
            //静态只能访问静态的成员
            System.out.println(phone);
            //System.out.println(age);//报错非静态字段不能再静态里面访问
            OuterThree outerThree=new OuterThree();
            System.out.println(outerThree.name);
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }
    }
}
